package tut.Struct.Struct;

import java.util.Iterator;
import java.util.Properties;
import java.util.Set;

public class PropertiesDemo {
	public static void main(String args[]) {
		Properties p = new Properties();
		p.setProperty("1", "m");
		p.setProperty("2", "h");
		p.setProperty("1", "b");

		System.out.println(p);

		System.out.println(p.getProperty("1"));
		System.out.println(p.getProperty("22"));
		System.out.println(p.setProperty("1", "m new"));

		System.out.println(p);

		Properties capitals = new Properties();
		Set states;
		String str;
		capitals.put("Illinois", "Springfield");
		capitals.put("Missouri", "Jefferson City");
		capitals.put("Washington", "Olympia");
		capitals.put("California", "Sacramento");
		capitals.put("Indiana", "Indianapolis");
		// Show all states and capitals in hashtable. ]
		states = capitals.keySet();
		// get set-view of keys
		Iterator itr = states.iterator();
		while (itr.hasNext()) {
			str = (String) itr.next();
			System.out.println("The capital of " + str + " is "	+ capitals.getProperty(str) + ".");
		}
		System.out.println();
		// look for state not in list -- specify default
		str = capitals.getProperty("Florida", "Not Found");
		System.out.println("The capital of Florida is " + str + ".");

	}

}
